home *** CD-ROM | disk | FTP | other *** search
- {****************************************************}
- { CToolText.p}
- {}
- { The ToolText Class}
- {}
- { A typical text tool for typing text in a Painting. A Caption, which}
- { is a subclass of CEditText, is created to handle the text. This}
- { actually becomes a subpane of the painting. The Pane itself is}
- { disposed after the typing is completed, but the bits within the}
- { Pane become part of the painting.}
- {}
- { SUPERCLASS = CPaintTask}
- {}
- { Copyright ⌐ 1989, Symantec Corporation. All rights reserved. }
- {}
- {****************************************************}
-
- unit CToolText;
-
- interface
-
- uses
- TCL, MoreTCL, ArtClassIntf;
-
- {** Class Constants **}
-
- const
- iTEXT = 5; { Index for Text Task name }
-
- implementation
-
-
-
- {*** C O N S T R U C T I O N / D E S T R U C T I O N M E T H O D S ***}
-
-
-
- {****************************************************}
- { IToolText}
- {}
- { Initialize a ToolText object}
- {}
- {****************************************************}
-
- procedure CToolText.IToolText (aPaintPane: CPaintPane; aPainting: CBitMap);
- begin
- IPaintTask(iTEXT, aPaintPane, aPainting);
-
- itsCaption := nil;
- done := FALSE;
- end;
-
-
- {****************************************************}
- { BeginTracking (OVERRIDE)}
- {}
- { Initial mouse down determines the location for the text}
- {}
- {****************************************************}
-
- procedure CToolText.BeginTracking (var startPt: Point);
- var
- theCaption: CCaption; { Altered by TCL Weaver 1.0 (5/9/90) }
-
- begin
- { Create a Caption Pane to handle }
- { keystrokes and text display }
-
- TextFont(gFontNum); { Set font characteristics }
- TextSize(gFontSize);
- TextFace(gFontStyle);
- { Note how the PaintPane is both }
- { the enclosure and supervisor }
- { of the Caption. This is }
- { important because we want the }
- { PaintPane to become the Gopher }
- { again when we get rid of the }
- { Caption pane. }
-
- new(theCaption); { Altered by TCL Weaver 1.0 (5/9/90) }
- itsCaption := theCaption;
- itsCaption.ICaption(itsPaintPane, itsPaintPane, PNTG_WIDTH, startPt.h, startPt.v);
-
- itsCaption.SetLineSpacing(gLineSpacing);
-
- itsCaption.Activate;
- gGopher := itsCaption;
- gSleepTime := 0;
- { Make Caption the Gopher so it }
- { receives key and menu commands }
-
- CDirector(itsPaintPane.itsSupervisor).itsGopher := itsCaption;
- end;
-
-
- {****************************************************}
- { DoTask (OVERRIDE)}
- {}
- { Finish off Text}
- {}
- {****************************************************}
-
- procedure CToolText.DoTask;
- var
- tFrame: Rect;
-
- begin
- if not done then
- begin { We have to save stuff for Undo, }
- { copy the image from the }
- { Caption to the Painting, then }
- { throw out the Caption. }
- itsCaption.Deactivate;
- itsCaption.GetFrame(tFrame);
- itsCaption.FrameToEnclR(tFrame);
-
- SaveForUndo(tFrame);
-
- itsCaption.DrawInPort(itsPainting.macPort);
- itsCaption.Free;
- CDirector(itsPaintPane.itsSupervisor).itsGopher := itsPaintPane;
- done := TRUE;
- end;
- end;
-
-
- {****************************************************}
- { Undo (OVERRIDE)}
- {}
- { Undo typing of text}
- {}
- {****************************************************}
-
- procedure CToolText.Undo;
- begin
- if not done then { We must be sure to finalize the }
- DoTask; { typing before undoing it. }
-
- inherited Undo;
- end;
-
-
- end.